package com.lucene.test.common;

import lombok.Getter;
import lombok.Setter;

/**
 * @author zoumy9
 * @date 2024/05/23 22:30
 **/
@Getter
@Setter
public class PageData<T> {
    private Page page;
    private T data;

    public PageData() {
    }

    public PageData(Page page, T data) {
        this.page = page;
        this.data = data;
    }

    public static PageData empty(Page page) {
        PageData pageData = new PageData(page, null);
        pageData.getPage().setTotal(0);
        return pageData;
    }

    public static PageData data(Page page, int total, Object data) {
        PageData pageData = new PageData(page, data);
        pageData.getPage().setTotal(total);
        return pageData;
    }
}
